import pickle

"""处理时间格式的函数"""
def sanitize(time_string):
    if "-" in time_string:
        spliter = "-"
    elif ":" in time_string:
        spliter = ":"
    else:
        return time_string
    (mins, secs) = time_string.split(spliter)
    return mins + '.' + secs


"""读取文件内容"""
def get_file_data(filename):
    try:
        with open(filename) as files:
            data = files.readline()
            return data.strip().split(",")
    except IOError as err:
        print("File Error" + err)


a_list = get_file_data("F:/data/a.txt")
b_list = get_file_data("F:/data/b.txt")
c_list = get_file_data("F:/data/c.txt")
d_list = get_file_data("F:/data/d.txt")

clear_a = sorted(set([sanitize(t) for t in a_list]), reverse=True)[0:3]
clear_b = sorted(set([sanitize(t) for t in b_list]), reverse=True)[0:3]
clear_c = sorted(set([sanitize(t) for t in c_list]), reverse=True)[0:3]
clear_d = sorted(set([sanitize(t) for t in d_list]), reverse=True)[0:3]

print(clear_a)
print(clear_b)
print(clear_c)
print(clear_d)


